import random, numpy as np

# 物品单价
price = [random.randint(10, 20) for i in range(10)]

# 物品数量
quantity = [random.randint(10, 20) for i in range(10)]

print(price)
print(quantity)

# 小计
subtotal = []
for index in range(len(price)):
    subtotal.append(price[index] * quantity[index])
print(subtotal)
print(sum(subtotal))

# numpy
# 将列表转为数组
price_pool = np.array(price)
quantity_pool = np.array(quantity)
print(price_pool * quantity_pool)
print(sum(price_pool * quantity_pool))